package fgoScript.entity;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import commons.entity.Constant;
import commons.entity.NativeCp;
import commons.util.GameUtil;
import fgoScript.constant.PointInfo;

import java.awt.*;
import java.util.ArrayList;
import java.util.List;

public class BStrategy {
    public static BStrategy bStrategy;

    public static BStrategy getInstance(){
//        if (bStrategy == null) {
            String filepath = NativeCp.getUserDir() + "/config/"+ Constant.FGO +"/BStrategy.json";
            bStrategy = JSONObject.parseObject(GameUtil.getJsonString(filepath), BStrategy.class);
//        }
        return bStrategy;
    }
    public static BStrategy getTrainStrategy(int num){
//        if (bStrategy == null) {
        String filepath = NativeCp.getUserDir() + "/config/"+ Constant.FGO +"/TrainStrategy"+ num +".json";
        bStrategy = JSONObject.parseObject(GameUtil.getJsonString(filepath), BStrategy.class);
//        }
        return bStrategy;
    }
    public static BStrategy getTrainStrategyByName(String name){

        String filepath = NativeCp.getUserDir() + "/config/"+ Constant.FGO +"/"+ Constant.STRATEGY + "/" + name;
        bStrategy = JSONObject.parseObject(GameUtil.getJsonString(filepath), BStrategy.class);

        return bStrategy;
    }
    private List<BRound> bRounds;
    private List<BServant> bServants;
    private List<Point> clothSkillPoints;
    private List<Point> changePersonPoints;
    private List<Point> fiveCardPoints;
    private int[][][] servantSkills;
    private String[][] cardSequence;
    private int[][][] afterClothSkills;
    private int[][][] clotheSkills;
    private int[][] npGos;
    private int[][] monsterSelects;
    private int maxBattleRounds;


    public int[][][] getAfterClothSkills() {
        return afterClothSkills;
    }

    public void setAfterClothSkills(int[][][] afterClothSkills) {
        this.afterClothSkills = afterClothSkills;
    }

    public List<BRound> getbRounds() {
        return bRounds;
    }

    public void setbRounds(List<BRound> bRounds) {
        this.bRounds = bRounds;
    }

    public List<BServant> getbServants() {
        return bServants;
    }

    public void setbServants(List<BServant> bServants) {
        this.bServants = bServants;
    }

    public int[][][] getServantSkills() {
        return servantSkills;
    }

    public void setServantSkills(int[][][] servantSkills) {
        this.servantSkills = servantSkills;
    }

    public int[][][] getClotheSkills() {
        return clotheSkills;
    }

    public void setClotheSkills(int[][][] clotheSkills) {
        this.clotheSkills = clotheSkills;
    }

    public int getMaxBattleRounds() {
        return maxBattleRounds;
    }

    public void setMaxBattleRounds(int maxBattleRounds) {
        this.maxBattleRounds = maxBattleRounds;
    }

    public List<Point> getClothSkillPoints() {
        return clothSkillPoints;
    }

    public void setClothSkillPoints(List<Point> clothSkillPoints) {
        this.clothSkillPoints = clothSkillPoints;
    }

    public int[][] getNpGos() {
        return npGos;
    }

    public void setNpGos(int[][] npGos) {
        this.npGos = npGos;
    }

    public List<Point> getFiveCardPoints() {
        return fiveCardPoints;
    }

    public void setFiveCardPoints(List<Point> fiveCardPoints) {
        this.fiveCardPoints = fiveCardPoints;
    }

    public List<Point> getChangePersonPoints() {
        return changePersonPoints;
    }

    public void setChangePersonPoints(List<Point> changePersonPoints) {
        this.changePersonPoints = changePersonPoints;
    }

    public String[][] getCardSequence() {
        return cardSequence;
    }

    public void setCardSequence(String[][] cardSequence) {
        this.cardSequence = cardSequence;
    }

    public int[][] getMonsterSelects() {
        return monsterSelects;
    }

    public void setMonsterSelects(int[][] monsterSelects) {
        this.monsterSelects = monsterSelects;
    }

    public static void main(String[] args) {
        List<BServant> bServants = new ArrayList<>();
        List<Point> skLocs1 = new ArrayList<>();
        List<Point> skLocs2 = new ArrayList<>();
        BServant bs1 = new BServant();
        bs1.setBjLoc(new Point(1,0));
        bs1.setNpLoc(new Point(1,0));
        skLocs1.add(new Point(1,0));
        skLocs1.add(new Point(1,0));
        skLocs1.add(new Point(1,0));
        bs1.setSkLocs(skLocs1);
        BServant bs2 = new BServant();
        bs2.setBjLoc(new Point(2,0));
        bs2.setNpLoc(new Point(2,0));
        skLocs2.add(new Point(2,0));
        skLocs2.add(new Point(2,0));
        skLocs2.add(new Point(2,0));
        bs2.setSkLocs(skLocs2);
        bServants.add(bs1);
        bServants.add(bs2);
        BStrategy bs = new BStrategy();
        List<BRound> BRounds = new ArrayList<>();
        BRound br1 = new BRound();
        BRound br2 = new BRound();
        BRound br3 = new BRound();
        List<Point> enemys = new ArrayList<>();
        List<Point> phases = new ArrayList<>();
        enemys.add(new Point(0,0));
        enemys.add(new Point(1,0));
        enemys.add(new Point(2,0));
        phases.add(new Point(0,0));
        phases.add(new Point(1,0));
        phases.add(new Point(2,0));
        br1.setEnemys(enemys);
        br1.setPhase(1);
        br1.setPhases(phases);
        br2.setEnemys(enemys);
        br2.setPhase(2);
        br2.setPhases(phases);
        br3.setEnemys(enemys);
        br3.setPhase(3);
        br3.setPhases(phases);
        BRounds.add(br1);
        BRounds.add(br2);
        BRounds.add(br3);

        bs.setbServants(bServants);
        bs.setbRounds(BRounds);
        String text = JSON.toJSONString(bs);
        System.out.println(text);
    }
}
